import { ref, Ref, inject } from "vue";
export const usePageScroll = (): {
  pageContainerRef: Ref;
  snapNext: () => void;
} => {
  const pageContainerRef = ref();
  const rootRef = inject("app_main_ref") as Ref;
  const snapNext = () => {
    const container = pageContainerRef.value;
    const offsetTop = container?.offsetTop;
    rootRef.value.scrollTo({
      top: offsetTop,
      behavior: "smooth",
    });
  };
  return {
    pageContainerRef,
    snapNext,
  };
};
